package org.scala.test.t002

abstract class A {
  def a() ;
}

class B(val name:String,val age:Int) extends A{
  private val n:String = name ;
  private val g:Int = age ;
  
  def this(name:String ){
    this(name,0)
     
  }
  override def a()={
    println("B  name:"+n +",age:"+g) ;
  }
  def b()={
    println("B  name:"+n +",age:"+g) ;
  }
}
// 只有一个主构造函数
class C(override val name:String, val g:Int,val address:String) extends B(name,g) with One{
  
  //都要是辅助构造函数，必须用主构造函数来构造
  def this(){ 
    this("",0,"");
  }
  
  def this(name:String,age:Int){ 
    this(name,age,null);
  }
  // 必须用 override 
   override def a():Unit={
     super.a()
     println("C") 
   }
   
}
object Test{
  def main(args: Array[String]): Unit = {
     val b = new C("lihc",30)
     b.a()
     println(b.name) ;
     b.b()
  }
}